<template>
    <div class="export-maintain-standard-wrap">
        <el-form label-width="100px" :model="exportMaintainStandardForm" :rules="exportMaintainStandardFormRules" ref="exportMaintainStandardForm" @submit.native.prevent>
            <el-form-item label="维保标准：" prop="maintainStandardId">
                <el-select filterable v-model="exportMaintainStandardForm.maintainStandardId" placeholder="请选择维保标准">
                    <el-option
                        v-for="obj in maintainStandardOptions"
                        :key="obj.id"
                        :label="obj.name"
                        :value="String(obj.id).replace('bz-', '')">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label-width="0" class="verifyidentity-button">
                <el-button @click.stop="closeDialogFun">取消</el-button>
                <el-button type="primary" @click="downloadMaintainStandard">下载</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { exportMaintainStandard } from '@/api/maintence'

export default {
    name: 'ExportMaintainStandard',
    props: {
        maintainStandardOptions: {
            type: Array,
            required: true
        },
        closeDialogFun: {
            type: Function,
            required: true
        }
    },
    data() {
        return {
            exportMaintainStandardForm: {
                maintainStandardId: ''
            },
            exportMaintainStandardFormRules: {
                maintainStandardId: [
                    { required: true, message: '请选择维保标准', trigger: 'change' }
                ]
            },
        }
    },
    methods: {
        // 下载
        downloadMaintainStandard() {
            let that = this
            that.$refs['exportMaintainStandardForm'].validate((valid) => {
                if (valid) {
                    // 下载
                    window.location.href = this.GLOBAL.baseURL + 'maintain/exportMaintainStandard?maintainStandardId=' + that.exportMaintainStandardForm.maintainStandardId
                } else {
                    return false
                }
            })
        }
    }
}
</script>
